<template>
	<div>
		<Header></Header>
		<el-main style="margin-top: 60px;">
			<el-row :gutter="20">
				<el-col :span="16">
					<div class="grid-content bg-purple">
						<el-card class="carousel">
							<el-carousel :interval="4000" type="card" height="300px">
								<el-carousel-item>
									<img class="medium" src="../assets/images/1.jpg">
								</el-carousel-item>
								<el-carousel-item>
									<img class="medium" src="../assets/images/2.jpg">
								</el-carousel-item>
								<el-carousel-item>
									<img class="medium" src="../assets/images/3.jpg">
								</el-carousel-item>
								<el-carousel-item>
									<img class="medium" src="../assets/images/4.jpg">
								</el-carousel-item>
							</el-carousel>
						</el-card>
					</div>
				</el-col>

				<el-col :span="8">
					<div class="grid-content bg-purple">
						<el-card class="news-text">
							<div slot="header" class="clearfix">
								<span>2021年11月4日 星期四</span>&nbsp;
								<i class="el-icon-location"></i>&nbsp;
								<span>广州市</span>&nbsp;
								<i class="el-icon-cloudy"></i>
								<span>23℃</span>
							</div>
							<div class="news" v-for="news in newsData.slice(0,6)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h1>{{news.title}}</h1>
									<br>
								</router-link>
							</div>								
						</el-card>
					</div>

				</el-col>
			</el-row>
			<el-row :gutter="20">
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<div class="news" v-for="news in newsData.slice(6,13)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h3>{{news.title}}</h3>
									<br>
								</router-link>
							</div>	
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<img class="sy" src="../assets/images/s1.jpeg" height="180px">
							<br>
							<div class="news" v-for="news in newsData.slice(13,16)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h3>{{news.title}}</h3>
									<br>
								</router-link>
							</div>
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card><img class="sy" src="../assets/images/s2.jpg" height="180px">
						<br>
							<div class="news" v-for="news in newsData.slice(16,19)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h3>{{news.title}}</h3>
									<br>
								</router-link>
							</div>
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card><img class="sy" src="../assets/images/s3.jpg" height="180px">
						<br>
							<div class="news" v-for="news in newsData.slice(19,22)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h3>{{news.title}}</h3>
									<br>
								</router-link>
							</div>
						</el-card>
					</div>
				</el-col>
			</el-row>
			<el-row :gutter="20">
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<div class="news" v-for="news in newsData.slice(22,29)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h3>{{news.title}}</h3>
									<br>
								</router-link>
							</div>	
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<img class="sy" src="../assets/images/s4.jpg" height="180px" width="300px">
							<br>
							<div class="news" v-for="news in newsData.slice(29,32)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h3>{{news.title}}</h3>
									<br>
								</router-link>
							</div>
							
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card><img class="sy" src="../assets/images/s5.jpeg" height="180px" width="300px">
						<br>
							<div class="news" v-for="news in newsData.slice(32,35)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h3>{{news.title}}</h3>
									<br>
								</router-link>
							</div>
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<img class="sy" src="../assets/images/s6.png" height="180px" width="300px">
						<br>
							<div class="news" v-for="news in newsData.slice(35,38)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h3>{{news.title}}</h3>
									<br>
								</router-link>
							</div>
						</el-card>
					</div>
				</el-col>
			</el-row>


			<el-row>
				<el-col :span="24">
					<div class="grid-content bg-purple-dark">
						<h1 class="h1-height">要闻</h1>
					</div>
				</el-col>
			</el-row>
			<el-row :gutter="20">
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<div class="news" v-for="news in newsData.slice(38,45)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h4>{{news.title}}</h4>
									<br>
								</router-link>
							</div>		
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<div class="news" v-for="news in newsData.slice(45,52)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h4>{{news.title}}</h4>
									<br>
								</router-link>
							</div>		
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<div class="news" v-for="news in newsData.slice(52,59)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h4>{{news.title}}</h4>
									<br>
								</router-link>
							</div>			
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<div class="news" v-for="news in newsData.slice(59,66)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h4>{{news.title}}</h4>
									<br>
								</router-link>
							</div>		
						</el-card>
					</div>
				</el-col>
			</el-row>

			<el-row>
				<el-col :span="24">
					<div class="grid-content bg-purple-dark">
						<h1 class="h1-height">生态环境</h1>
					</div>
				</el-col>
			</el-row>
			
			<el-row :gutter="20">
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<div class="news" v-for="news in newsData.slice(66,73)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h4>{{news.title}}</h4>
									<br>
								</router-link>
							</div>		
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<div class="news" v-for="news in newsData.slice(73,80)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h4>{{news.title}}</h4>
									<br>
								</router-link>
							</div>	
						</el-card>
					</div>
				</el-col>
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<div class="news" v-for="news in newsData.slice(33,40)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h4>{{news.title}}</h4>
									<br>
								</router-link>
							</div>		
						</el-card>
					</div>
				</el-col>
				
				<el-col :span="6">
					<div class="grid-content bg-purple">
						<el-card>
							<div class="news" v-for="news in newsData.slice(15,22)">
								<router-link style="color: black;" :to="{name: 'NewsDetail', params:{newsId: news.id}}">
									<h4>{{news.title}}</h4>
									<br>
								</router-link>
							</div>		
						</el-card>
					</div>
				</el-col>
			</el-row>

		</el-main>
		<Footer></Footer>
	</div>
</template>

<script>
	import Header from "@/components/Header"
	import Footer from "@/components/Footer"

	export default {
		name: 'news',
		components: {
			Header,
			Footer
		},
		data() {
			return {
				
				//新闻内容
				newsData:{
					
				},

			}

		},
		methods: {
			getNews(){
				this.$axios.get('/newsList').then(res => {
					this.newsData = res.data.data
				})
				
			},
		},
		created() {
			this.getNews()
		}
	}
</script>

<style scoped>

	
	.clearfix{
		font-size: 18px;
	}
	/* 轮播图 */
	/* 卡片 */
	.carousel {
		width: auto;
		height: 360px;
	}

	.el-carousel__item h3 {
		color: #475669;
		font-size: 15px;
		opacity: 0.75;
		line-height: 200px;
		margin: 0;
	}

	.el-carousel__item:nth-child(2n) {
		background-color: #99a9bf;
	}

	.el-carousel__item:nth-child(2n+1) {
		background-color: #d3dce6;
	}

	/* 日期天气 */
	.news-text {
		margin-top: 0px;
		font-size: 12px;
		min-height: 50px;
		width: auto;
	}

	/* 新闻 */
	.news {
		/* 不换行*/
		white-space: nowrap;
		/* 超出文本隐藏*/
		overflow: hidden;
		/* 超出显示... */
		text-overflow:ellipsis;
	}
	.h1-height {
		background-color: #efefef;
		color: #555500;
		text-indent: 1em;
		border-left: #ffd04b 3px solid;
		line-height: 50px;
	}
</style>
